package com.ysu.shop.pojo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.ysu.shop.pojo.BasePojo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * <p>
 * 
 * </p>
 *
 * @author 霍京
 * @since 2021-3-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pay")
public class Pay extends BasePojo {

    private static final long serialVersionUID = 1L;

    /**
     * 用户的id
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 支付的订单号
     */
    @TableField("order_no")
    private String orderNo;

    /**
     * 付款类型 0表示货到付款 1表示支付宝 2表示微信
     */
    @TableField("pay_platform")
    private String payPlatform;

    /**
     * 支付的流水号 时间戳+用户id
     */
    @TableField("platform_number")
    private String platformNumber;

    /**
     * 支付状态 0表示支付成功 1表示支付不成功
     */
    @TableField("platform_status")
    private String platformStatus;

    /**
     * 收货人姓名
     */
    @TableField("name")
    private String name;

    /**
     * 收货人电话号码
     */
    @TableField("phone")
    private String phone;


    /**
     * 收货地址
     */
    @TableField("detail_addr")
    private String detailAddr;

    /**
     * 实际付款金额
     */
    @TableField("payment")
    private BigDecimal payment;

    public void addPay(Address addr){
        this.userId = addr.getUserId();
        this.name = addr.getReceiverName();
        this.phone = addr.getReceiverPhone();
        this.platformNumber = System.currentTimeMillis()+""+this.userId;
    }

}
